package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created this one by HMH on 2017/9/29.
 */
public class code257_easy {
    static class Solution {
        public List<String> binaryTreePaths(TreeNode root) {
            if (root != null) {
                visit(root, "");
            }
            return result;
        }

        public void visit(TreeNode root, String path) {
            if (root.left != null) {
                visit(root.left, path + root.val + "->");
            }
            if (root.right != null) {
                visit(root.right, path + root.val + "->");
            }
            if (root.left == null && root.right == null) {
                result.add(path + root.val);
            }
        }

        List<String> result = new ArrayList<>();

    }

    public static void main(String[] args){

    }

}
